package org.dfl.plugin.perspectives;

import org.dfl.plugin.navigator.ProjectNavigator;
import org.dfl.plugin.views.debug.HistoriesTreeView;
import org.dfl.plugin.views.debug.TokensTreeView;
import org.dfl.plugin.views.debug.TreeElemPreview;
import org.eclipse.ui.IFolderLayout;
import org.eclipse.ui.IPageLayout;
import org.eclipse.ui.IPerspectiveFactory;
import org.eclipse.ui.console.IConsoleConstants;

/**
 * perspective used to run and debug a dataflow
 * @author Piotr Wlodarczyk
 *
 */
public class DflRunPerspective implements IPerspectiveFactory {
	public final static String ID = "org.dfl.plugin.perspectives.debugperspective";
	
	public void createInitialLayout(IPageLayout layout) {
		String editorArea = layout.getEditorArea();

		layout.addStandaloneView(HistoriesTreeView.ID, true, IPageLayout.RIGHT, 0.75f, editorArea);
		layout.addStandaloneView(TokensTreeView.ID, true, IPageLayout.BOTTOM, 0.5f, HistoriesTreeView.ID);
		IFolderLayout preview = layout.createFolder("preview",IPageLayout.BOTTOM, 0.5f, TokensTreeView.ID);
		preview.addView(TreeElemPreview.ID);

		IFolderLayout bottom = layout.createFolder("dflrunbottom",IPageLayout.BOTTOM,0.80f,editorArea);
		bottom.addView(IConsoleConstants.ID_CONSOLE_VIEW);
	    layout.setEditorAreaVisible(true);
	    
	    setContentsOfShowViewMenu(layout);
	}
	
	/**
	 * Sets the intial contents of the "Show View" menu.
	 */
	protected void setContentsOfShowViewMenu(IPageLayout layout) {
		layout.addShowViewShortcut(TokensTreeView.ID);
		layout.addShowViewShortcut(HistoriesTreeView.ID);
		layout.addShowViewShortcut(ProjectNavigator.ID);
		layout.addShowViewShortcut(IConsoleConstants.ID_CONSOLE_VIEW);
		layout.addShowViewShortcut(IPageLayout.ID_PROBLEM_VIEW);
	}
}
